package com.ruoyi.web.controller.subMajors;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.SubMajor;
import com.ruoyi.system.service.impl.SubMajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/subMajors/subMajors")
public class SubMajorsController extends BaseController {
    @Autowired
    private SubMajorService subMajorService;

    //搜索查询功能
    @PostMapping("/select")
    public List<SubMajor> selectSubMajor(@RequestBody SubMajor major) {
        List<SubMajor> majors = subMajorService.selectSubMajorList(major);
        return majors;
    }

    /**
     * 获取岗位列表
     */
//    @PreAuthorize("@ss.hasPermi('system:post:list')")
    @GetMapping("/list")
    public TableDataInfo list(SubMajor major)
    {
        startPage();
        List<SubMajor> list = subMajorService.selectPostList(major);
        return getDataTable(list);
    }


    //添加专业功能
    @PostMapping("/insert")
    public String insertSubMajor(@RequestBody SubMajor major) {
        String str = subMajorService.insertSubMajor(major);
        return str;
    }

    //批量删除专业功能
    @PostMapping("/delete")
    public String deleteSubMajor(@RequestBody List<SubMajor> majors) {
        String str = subMajorService.deleteSubMajor(majors);
        return str;
    }
    //修改专业功能,根据id进行修改
    @PostMapping("/update")
    public String updateSubMajor(@RequestBody SubMajor major) {
        String str = subMajorService.updateSubMajor(major);
        return str;
    }

}
